﻿using System.ComponentModel.DataAnnotations;
using TrackSystem.Entities.Extensions;
using TrackSystem.IO.Formula;
using TrackSystem.IO.Utils;

namespace TrackSystem.IO.Data
{
    public class RegDefine
    {
        /// <summary>
        /// 变量名称
        /// </summary>
        public required string Name { get; set; }

        /// <summary>
        /// 变量种类
        /// </summary>
        public VarSerialEnum Serial { get; set; }

        /// <summary>
        /// 变量类型
        /// </summary>
        public DataTypeEnum VarType { get; set; } = DataTypeEnum.DOUBLE;

        /// <summary>
        /// 变量来源的ID
        /// </summary>
        public int SnrloopId { get; set; }

        /// <summary>
        ///  变量来源的序号
        /// </summary>
        public int SnrloopIndex { get; set; }

        /// <summary>
        /// 变量是否是只读的
        /// </summary>
        public bool ReadOnly { get; set; }

        /// <summary>
        /// 自定义变量的计算公式
        /// </summary>
        public string? ClacuateFormula { get; set; }

        /// <summary>
        /// 变量是否需要记录
        /// </summary>
        public bool IsRecord { get; set; }

        /// <summary>
        /// 数据记录周期
        /// </summary>
        public int RecordCycle { get; set; }

        /// <summary>
        /// 变量是否触发报警
        /// </summary>
        public AlarmTypeEnum AlarmSetting { get; set; }

        /// <summary>
        /// 当前报警状态
        /// </summary>
        public int CurrentAlarm { get; set; }

        /// <summary>
        /// 变量值高报警设定
        /// </summary>
        public OperandDef HighAlarmSet { get; set; }

        /// <summary>
        /// 变量值低报警设定
        /// </summary>
        public OperandDef LowAlarmSet { get; set; }

        /// <summary>
        /// 自定义变量的中缀表达式
        /// </summary>
        public Stack<ExprItem>? exprStack { get; set; }

        /// <summary>
        /// 速度计算类型
        /// </summary>
        public SpeedHelper? Speed;

        /// <summary>
        /// 滤波计算类
        /// </summary>
        public FilterHelper? Filter;

        /// <summary>
        /// 显示自定义变量计算成功次数
        /// </summary>
        public int ClacSucc { get; set; }
        
        /// <summary>
        /// 变量当前值
        /// </summary>
        public OperandDef CurrentVal { get; set; }
        
        /// <summary>
        /// 变量历史值
        /// </summary>
        public OperandDef LastVal { get; set; }
        
    }
}
